home *** CD-ROM | disk | FTP | other *** search
- BEGIN {
- terminal_leader["\n\n"]=""
- #{{{}}}
- # {{{ mark used keys
- used["left"]=1
- used["right"]=1
- used["up"]=1
- used["down"]=1
- used["prev_page"]=1
- used["next_page"]=1
- used["rubout"]=1
- used["backspace"]=1
- used["home"]=1
- used["begin"]=1
- used["end"]=1
- used["delline"]=1
- used["clreol"]=1
- used["suspend"]=1
- used["open"]=1
- used["close"]=1
- used["command"]=1
- used["shift-command"]=1
- used["exit"]=1
- used["shift-exit"]=1
- used["save"]=1
- used["select"]=1
- used["shift-help"]=1
- used["help"]=1
- used["refresh"]=1
- # }}}
- }
- #{{{ starting a terminal
- /^\(terminal \([^ ]+\) *$/ {
- current_term=substr($2,2,length($2)-2)
- if (used[current_term]) {
- print("ignoring duplicate terminal ("current_term").")
- current_term=""
- } else
- used[current_term]=1
- term_data=""
- next
- }
- #}}}
- #{{{ end a terminal
- /^\) *$/ {
- term_data="\n"term_data"\n"
- if (terminal_leader[term_data]=="")
- terminal_leader[term_data]=current_term
- else
- terminal_group[term_data]=terminal_group[term_data]" "current_term
- current_term=""
- next
- }
- #}}}
- #{{{ skip lines outside of terminals
- current_term=="" {
- next
- }
- #}}}
- #{{{ skip invalid or unused aliases
- { critical="" }
- #{{{ escape not(O or [) -> critical
- /^ *\(alias ([^ ]+) \( C-\[ "[^O[](.*) \)\) *$/ {
- critical=$5
- }
- #}}}
- #{{{ esc [ M == mouse sequence -> critical
- /^ *\(alias ([^ ]+) \( C-\[ "\[ "M(.*) \)\) *$/ {
- critical=$6
- }
- #}}}
- #{{{ escape C-. -> critical
- /^ *\(alias ([^ ]+) \( C-\[ C-.(.*) \)\) *$/ {
- critical=$5
- }
- #}}}
- #{{{ C-. -> critical
- /^ *\(alias ([^ ]+) \( C-[ABCDEFGHIJKLMNOPQRSTUVWXYZ@_\^].* \)\) *$/ {
- critical=$4
- }
- #}}}
- critical!="" {
- # if (used[$2])
- # print("skipping "current_term" \t"critical":\t"$0)
- next
- }
- #}}}
- #{{{ store valid aliases
- { if (used[$2]) term_data=term_data $0 "\n" }
- #}}}
- END {
- # {{{ print em-term-list file
- print("; This file is generated by make(1), listing known terminals") >"em-term-list"
- printf("(") >"em-term-list"
- for ( i in terminal_leader )
- if (i!="\n\n")
- printf(" %s",terminal_leader[i]) >"em-term-list"
- printf(" )\n") >"em-term-list"
- # }}}
- # {{{ print em-term-alias file
- print("; This file is generated by autoalias(1), listing keys for known terminals") >"em-term-alias"
- for ( i in terminal_leader )
- if (i!="\n\n") {
- printf("{{{ terminal %s%s\n",terminal_leader[i],terminal_group[i]) >"em-term-alias"
- printf("(terminal (%s)\n%s)\n",terminal_leader[i],i) >"em-term-alias"
- if (terminal_group[i]!="")
- printf("(termalias %s (%s ))\n",terminal_leader[i],terminal_group[i]) >"em-term-alias"
- printf("}}}\n") >"em-term-alias"
- }
- # }}}
- }
-